from flask_sqlalchemy import SQLAlchemy
from marshmallow import fields, Schema

db = SQLAlchemy()


# 此文件声明项目中所有实体对象
class User(db.Model):
    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(32), unique=True)
    password = db.Column(db.String(64))
    age = db.Column(db.Integer)
    sex = db.Column(db.String(2))
    email = db.Column(db.String(64))
    phone = db.Column(db.String(32))
    address = db.Column(db.String(128))


#序列化工具类
class UserSchema(Schema):
    id = fields.Integer()
    username = fields.Str()
    password = fields.Str()


class Dept(db.Model):
    __tablename__ = 'dept'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(32))
    location = db.Column(db.String(64))
    manager = db.Column(db.String(32))